﻿var webpack = require('webpack');
var HtmlwebpackPlugin = require('html-webpack-plugin');
var path = require("path");
var ExtractTextPlugin = require("extract-text-webpack-plugin");

//var goCssExtractor = new ExtractTextPlugin('css/go.css');

module.exports = {
    // 页面入口文件配置
    entry : {
        'main/index': './js/view/main/index.js',
        'main/go': './js/view/main/go.js',
        'main/go-test': './js/view/main/go-test.js',
        //'view/main/jquery':'jquery',
        'public/bootstrap':'bootstrap-loader',
    },
    // 入口文件输出配置
    output : {
        path : path.join(__dirname,'..','..','dist'),
        filename : 'js/[name].bundle.js'
    },
    devtool: 'eval-source-map',
    module: {
        // 加载器配置
        loaders: [
        {test: /\.js$/,loader: 'babel-loader!jsx-loader?harmony' },
        //{test: /\.css$/,loader: 'style-loader!css-loader'},
        {test: /\.css$/,loader:ExtractTextPlugin.extract("style-loader","css-loader")},
	    {test: /\.scss$/, loaders:['style','css','sass']},
	    {test: /\.(png|jpe?g|ico|bmp|gif)$/,loader: 'file?limit=10000&name=./img/[name]-[hash:8].[ext]'},
	    {test: /\.woff2?(\?v=[0-9]\.[0-9]\.[0-9])?$/ ,loader : 'file?limit=10000&mimetype=application/font-woff&name=./font/[name]-[hash:8].[ext]'},
	    {test: /\.(ttf|eot|svg)(\?[\s\S]+)?$/, loader : 'file?name=./font/[name]-[hash:8].[ext]'},
	    //{test: /bootstrap-sass\/assets\/javascripts\//, loader: 'imports-loader' },
    	]        
    },
    // 其他解决方案配置
    resolve: {
        extensions: ['', '.js', '.jsx', '.css', '.json','.scss'],
    },
	sassLoader:{
		includePaths:[path.resolve(__dirname,'../../node_modules/bootstrap-sass')]
	},
    // 插件项
    plugins : [
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false,
            },
            output: {
                comments: false,
            },
        }),
        new webpack.ProvidePlugin({
        	$:'jquery',
        	jQuery:'jquery',
        	"window.jQuery":'jquery'
        }),
        new webpack.HotModuleReplacementPlugin(),
        new webpack.ProvidePlugin({
	      'window.Tether': 'tether',
	    }),
		new HtmlwebpackPlugin({
		      title: 'empty page',
		      chunks:['main/index','public/bootstrap'],
		      template:'template/index.html',
		      filename:  'index.html',
		}),
		new HtmlwebpackPlugin({
		      title: 'empty page',
		      chunks:[],
		      template:'template/index.html',
		      filename:  'empty.html',
		}),
		new HtmlwebpackPlugin({
		      chunks:['main/go','public/bootstrap'],
		      template:'template/go.html',
			  title: '在线记谱本',
		      filename:  'go.html',
			  hash:true,
		}),
		new HtmlwebpackPlugin({
		      title: '在线记谱本测试页面',
		      chunks:['main/go-test','public/bootstrap'],
		      template:'template/go.html',
		      filename:  'go-test.html',
		}),
		new ExtractTextPlugin("style.css"),
    ]
}